<?php
require_once($_SERVER['DOCUMENT_ROOT'] . "/" . $_SESSION['SiteFolder'] . "System/Date.class.php");
$date = new Date();

require_once($_SERVER['DOCUMENT_ROOT'] . "/" . $_SESSION['SiteFolder'] . "System/MuDatabase.class.php");
$db = new MuDatabase();

require_once($_SERVER['DOCUMENT_ROOT'] . "/" . $_SESSION['SiteFolder'] . "System/Account.class.php");
$acc = new Account($db);

require_once($_SERVER['DOCUMENT_ROOT'] . "/" . $_SESSION['SiteFolder'] . "System/Character.class.php");
$ch = new Character();

require_once($_SERVER['DOCUMENT_ROOT'] . "/" . $_SESSION['SiteFolder'] . "System/Guild.class.php");
$gd = new Guild();

/* CASTLE SIEGE */
require_once($_SERVER['DOCUMENT_ROOT'] . "/" . $_SESSION['SiteFolder'] . "System/Guild.class.php");
$gd = new Guild();

$db->Query("SELECT g.G_Name,g.G_Master,g.G_Mark,cs.Points,g.Number FROM Guild g, Z_CastleSiegeWins cs WHERE g.G_Name = cs.Guild AND g.G_Name = (SELECT OWNER_GUILD FROM MuCastle_DATA)");

if ($db->NumRows() > 0) {
    $data = $db->GetRow();
    $CSOwner = $data[0];
    $CSKing = $data[1];
    $CSMark = $gd->PrintGuildMark(bin2hex($data[2]), 85);
    $CSWins = $data[3];
    $CSOwnersNumber = $data[4];

    $db->Query("SELECT g.G_Name, COUNT(m.G_Name) FROM Guild g, GuildMember m WHERE g.G_Name = m.G_Name AND g.G_Union = '$CSOwnersNumber' GROUP BY g.G_Name");
    $NumAllies = $db->NumRows();
    $CSAllies = array();
    $CSMembers = 0;
    for ($i = 0; $i < $NumAllies; $i++) {
        $result = $db->GetRow();
        if ($result[0] != $CSOwner)
            $CSAllies[$i] = $result[0];
        $CSMembers += $result[1];
    }
}
else {
    $CSOwner = "-";
    $CSKing = "-";
    $CSMark = "";
    $CSWins = "-";
    $CSAllies = array();
    $CSMembers = "-";
}

$db->Query("SELECT DATEADD(day, -1, SIEGE_END_DATE) FROM MuCastle_DATA");
$data = $db->GetRow();

$dateClass = new Date();
$NextCSDate = $dateClass->DateFormat($data[0]);
///////////////////// 
// RANKINGS TOP 5
$db->Query("SELECT TOP 1 AccountID,Name,ResetCount FROM Character ORDER BY ResetCount DESC");
$resets = $db->GetRow();

$db->Query("SELECT TOP 1 AccountID,Name,ResetCount FROM Character ORDER BY ResetCount DESC");
$resetsday = $db->GetRow();

$db->Query("SELECT TOP 1 AccountID,Name,ResetCount FROM Character ORDER BY ResetCount DESC");
$resetsweek = $db->GetRow();

$db->Query("SELECT TOP 1 AccountID,Name,ResetCount FROM Character ORDER BY ResetCount DESC");
$resetsmonth = $db->GetRow();

$db->Query("SELECT TOP 1 AccountID,Name,MasterResetCount FROM Character ORDER BY MasterResetCount DESC");
$grandresets = $db->GetRow();

$db->Query("SELECT TOP 1 AccountID,Name,OnlineHours FROM MEMB_STAT ORDER BY OnlineHours DESC");
$online = $db->GetRow();

/* JOGADORES ATIVOS */
$MaximoOnline = 100;
$db->Query("SELECT COUNT(memb___id) FROM MEMB_STAT WHERE ConnectStat = '1'");
$data = $db->GetRow();
$TotalOnline = number_format($data[0], 0, "", ".");
$Percent = ($data[0] / $MaximoOnline);
$Barra = (int) (330 * $Percent);
////////////////////////

/* INFOS */

$db->Query("SELECT COUNT(memb___id) FROM MEMB_INFO");
$data = $db->GetRow();
$TotalAcc = number_format($data[0], 0, "", ".");

$db->Query("SELECT COUNT(Name) FROM Character");
$data = $db->GetRow();
$TotalChar = number_format($data[0], 0, "", ".");

$db->Query("SELECT COUNT(G_Name) FROM Guild");
$data = $db->GetRow();
$TotalGuild = number_format($data[0], 0, "", ".");

$db->Query("SELECT COUNT(idx) FROM Z_BlockedUsers WHERE status = 1");
$data = $db->GetRow();
$TotalBan = number_format($data[0], 0, "", ".");
?>
<?php require ("Templates/F-Team/config/F-Team.php"); ?>
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="utf-8">
<title>{title}</title>    
<meta name="keywords" content="MMPG,MuOnline,Servidor,Servidores,Games,Game,MuOnline,Ferrarezi,F-Team" />
<meta name="description" content="{title} - Powered by F-Team" />
<meta name="keywords" content="MuOnline, Mu, F-Team, Developers, FDev, F-Team, Ferrarezi, RPG, MMORPG" />
<meta name="Author" content="F-Team Developers" />
<link type="text/css" rel="stylesheet" href="/{tpldir}_Css/common.css" />
<script type="text/javascript" src="/{tpldir}_Script/ajax.js"></script>
<script src="/{tpldir}script/jquery-1.8.3.min.js"></script>
<script src="/{tpldir}script/scritps.js"></script>
<link type="text/css" rel="stylesheet" href="/{tpldir}_Script/fancybox/jquery.fancybox-1.3.4.css" />
<script type="text/javascript" src="/{tpldir}_Script/fancybox/jquery.mousewheel-3.0.4.pack.js"></script>
<script type="text/javascript" src="/{tpldir}_Script/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
<link rel="stylesheet" href="/{tpldir}images/slide/responsiveslides.css">
<link rel="stylesheet" href="/{tpldir}images/slide/themes.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="/{tpldir}images/slide/responsiveslides.min.js"></script>
<script type='text/javascript' src='/{tpldir}script/jquery.scrollTo-min.js'></script>
<script type='text/javascript' src='/{tpldir}script/jquery.scrollShow-min.js'></script>
<script type='text/javascript' src='/{tpldir}script/init.js'></script>
<script type="text/javascript" src="/{tpldir}script/jquery.js"></script>
<script type="text/javascript" src="/{tpldir}script/basic.js"></script>
<script>
    // You can also use "$(window).load(function() {"
    $(function () {

      // Slideshow 1
      $("#slider1").responsiveSlides({
        auto: true,
        pager: true,
        nav: true,
        speed: 500,
        maxwidth: 800,
        namespace: "centered-btns"
      });

      // Slideshow 2
      $("#slider2").responsiveSlides({
        auto: true,
        pager: true,
        nav: true,
        speed: 500,
        maxwidth: 800,
        namespace: "transparent-btns"
      });

      // Slideshow 3
      $("#slider3").responsiveSlides({
        auto: true,
        pager: false,
        nav: true,
        speed: 500,
        maxwidth: 800,
        namespace: "large-btns"
      });

    });
  </script>
</head>
<body>
    <style>
        .icon-whatsapp {
            position: absolute;
            margin-top: 9px;
            margin-left: 68px;
            width: 57px;
            height: 57px;
            cursor:pointer;
            z-index: 3;
        }

        .icon-whatsapp2 {
            position: absolute;
            width: 201px;
            height: 227px;
            cursor:pointer;
            z-index: 5;
            float: left;
            right: 0;
        }
    </style>
    <div id="TopoHeader">
    <div class="icon-whatsapp">
            <a href="https://www.facebook.com/muteensoficial/" target="_blank"><img src="/{tpldir}images/facebook_icone.png" border="0" alt="Página do Facebook"/></a>
        </div>
    </div>
    <div id="TopoHeader2">
    <div class="icon-whatsapp2">
            <a href="?page=rankings" target="_blank"><img src="/{tpldir}images/box_emperor.png" border="0" alt="Página do Facebook"/></a>
        </div>
    </div>
<div id="mainwrapper">
        <div class="mainvisual">
            <div class="centerimages"></div>
            <div class="leftimages"></div>
            <div class="rightimages"></div>
        </div>
     
        <!-- Header -->
        <div id="mainheader">  
    <div id="status">
      <div class="server" online="0">
        <div class="name">Upar + PVP<div style=" position:absolute; top:-2px; left:70px;">
<?PHP
$onlineoffline = $IPVPS;
if ($check=@fsockopen($onlineoffline,$PORTA_1,$ERROR_NO,$ERROR_STR,(float)0.5)) 
    { 
    fclose($check); 
    echo '<img src="/{tpldir}images/common/temp/on.png" />'; 
    }
else 
    { 
    echo '<img src="/{tpldir}images/common/temp/off.png" />'; 
    } 
?>
</div></div>
<div class="name2">CastleSiege<div style=" position:absolute; top:-2px; left:-23px;">
<?PHP
$onlineoffline = $IPVPS;
if ($check=@fsockopen($onlineoffline,$PORTA_2,$ERROR_NO,$ERROR_STR,(float)0.5)) 
    { 
    fclose($check); 
    echo '<img src="/{tpldir}images/common/temp/on.png" />'; 
    }
else 
    { 
    echo '<img src="/{tpldir}images/common/temp/off.png" />'; 
    } 
?>
</div></div>
        <div class="load"><div class="load-line"></div></div>
    <div class="online"><span style="font-family:TrajanPro-Bold;">Total Online</span><br /><br /><a  href="?page=onlines"><?php echo $TotalOnline; ?></a></div>
    <a  href="?page=onlines"><div style="position:absolute; top:15px; left:200px;"><img src="/{tpldir}images/common/temp/status_b.png" alt="" width="113" height="113" /></div></a>
      </div>  
    </div>          
            <div class="mainBtnStartGame">
                <div class="main_visual_obj"></div>
            </div>
     
        </div>
        <!-- //Header -->
 <div id="mainbody">   
<!-- Body Left -->
            <div id="mainleft">
<div class="pvp">
  <?php
$db->Query("SELECT TOP 1 AccountID,Name, ".$COLUMN_PK.",image FROM Character ORDER BY ".$COLUMN_PK." DESC");{
$namepvp=$db->GetRow();
?>
<div class="pvp_cod">
<?php echo $acc->GetAccountImage($db->GetRow('AccountID'), $db, 110, 110); ?><br /></div>
<div class="pvp_img"><img src="/{tpldir}images/menu/rei_pvp.png" width="190" height="254" /></div>
<div class="pvp_user">
<a class='rank_status' href="?c=Rankings"><?=$namepvp;?><a/>
  <?
}
?>
</div>
</div>
<div class="menu_top"></div>  
                <div class="menu">
                <ul> 
          <a href="?c=Home"><li class="inicio"></li></a>
                    <a href="?c=AccRegister"><li class="cadastro"></li></a>
                    <a href="?c=Downloads"><li class="download"></li></a>
                    <a href="?c=Rankings"><li class="ranking"></li></a>
          <a href="?c=WebShop"><li class="shopping"></li></a>
          <a href="?c=VIP"><li class="tutorial"></li></a>
          <a href="?c=HelpDesk"><li class="contatos"></li></a>
          <li class="menu_footer"></li>   
                </ul>
            </div>
            <div class="shoppings">
            <div class="shopping_top"></div>
            <div class="shopping_meio">
            <div style="margin-left:42px;">
  <ul id="screen">
    <div style="margin-left:-42px; margin-top:90px; position:absolute;"><a id="left"><div class="screen_button_left"></div></a></div>
<li id="view">
  <ul id="images">
    <li>
        <div style=' height:249px; position:relative'>
        <div style='margin-top:58px; text-align:center; position:absolute;'><img src='http://www.viciadosmu.com.br/paginas/images/c_bk.jpg' style="width: 125px; height:125px;" /></div>
        <div style='text-align:center; position:absolute;'><img src='/{tpldir}images/shopping/fundo.png' style="width: 177px; height:249px;" /></div>
        <br />
        <div class='screen_text' style='margin-top:22px;position:absolute; width:185px; text-align:center; font-size:14px; text-transform: uppercase;'>Kit DK Full</div>
        <br />
        <div class='screen_text' style='margin-top:174px; position:relative; width:185px; font-size:11px; color:#CC9900; text-align:center; font-family:gadugi-bold; text-transform: uppercase;'>Pre&ccedil;o: R$ 50,00</div></div>
  </li>
  <li>
        <div style=' height:249px; position:relative'>
        <div style='margin-top:58px; text-align:center; position:absolute;'><img src='http://www.viciadosmu.com.br/paginas/images/c_bk.jpg' style="width: 125px; height:125px;" /></div>
        <div style='text-align:center; position:absolute;'><img src='/{tpldir}images/shopping/fundo.png' style="width: 177px; height:249px;" /></div>
        <br />
        <div class='screen_text' style='margin-top:22px;position:absolute; width:185px; text-align:center; font-size:14px; text-transform: uppercase;'>Kit BK Full</div>
        <br />
        <div class='screen_text' style='margin-top:174px; position:relative; width:185px; font-size:11px; color:#CC9900; text-align:center; font-family:gadugi-bold; text-transform: uppercase;'>Pre&ccedil;o: R$ 50,00</div></div>
  </li>
  <li>
        <div style=' height:249px; position:relative'>
        <div style='margin-top:58px; text-align:center; position:absolute;'><img src='http://www.viciadosmu.com.br/paginas/images/c_bk.jpg' style="width: 125px; height:125px;" /></div>
        <div style='text-align:center; position:absolute;'><img src='/{tpldir}images/shopping/fundo.png' style="width: 177px; height:249px;" /></div>
        <br />
        <div class='screen_text' style='margin-top:22px;position:absolute; width:185px; text-align:center; font-size:14px; text-transform: uppercase;'>Kit Teste</div>
        <br />
        <div class='screen_text' style='margin-top:174px; position:relative; width:185px; font-size:11px; color:#CC9900; text-align:center; font-family:gadugi-bold; text-transform: uppercase;'>Pre&ccedil;o: R$ 50,00</div></div>
  </li>
    </ul>
</li>
    <div style="margin-left:171px; margin-top:90px; position:absolute;"><a id="right" ><div class="screen_button_right"></div></a></div>
      </ul>

            </div>
            </div>
            <div class="shopping_footer"><a href="?page=webshop"><div class="button_screen"></div></a></div>
            </div>
      <div class="shoppings">
            <div class="parceiro_top"></div>
      <div class="shopping_meio">
      <center>
      <a href="http://fteamdevelopers.com/" target="_blank"><img src="/{tpldir}images/shopping/parceria.png" width="218" height="46" /></a>
      </center>
      </div>
      <div class="shopping_footer"></div>
      </div>
            </div>
            <!-- //Body Left -->
            <div id="FerrareziMUWebContentDiv">
                {content}
            </div>
 <!-- Body Center -->
            

            <div id="mainright">
 
 <!-- Login -->        
<div class="login_top"></div>
<div class="login_meio">
    {login_ajax}
</div>
<div class="login_fim"></div>
<br />
<!-- informações -->
<div class="info_top"></div>
<div class="info_meio">
<ul>
<li>
<p style=" padding-left:5px; position:absolute;"><img src="/{tpldir}images/informacao/ponto.png" width="16" height="16" /></p><span style="margin-left:25px;">Total de Contas: <strong><?php echo $TotalAcc; ?></strong></span>
<p style="position:absolute; top:8px;"><img src="/{tpldir}images/informacao/line.png" width="263" height="38" /></p>
</li>

<li>
<p style=" padding-left:5px; position:absolute;"><img src="/{tpldir}images/informacao/ponto.png" width="16" height="16" /></p><span style="margin-left:25px;">Total de Chars: <strong><?php echo $TotalChar; ?></strong></span>
<p style="position:absolute; top:8px;"><img src="/{tpldir}images/informacao/line.png" width="263" height="38" /></p>
</li>


<li>
<p style=" padding-left:5px; position:absolute;"><img src="/{tpldir}images/informacao/ponto.png" width="16" height="16" /></p><span style="margin-left:25px;">Total Guild: <strong><?php echo $TotalGuild; ?></strong></span>
<p style="position:absolute; top:8px;"><img src="/{tpldir}images/informacao/line.png" width="263" height="38" /></p></li>

<li>
<p style=" padding-left:5px; position:absolute;"><img src="/{tpldir}images/informacao/ponto.png" width="16" height="16" /></p>
<span style="margin-left:25px;">Contas Banidas: <a href="?page=banned&amp;type=characters"><strong><a href="?c=BlockedUsers"><?php echo $TotalBan; ?></a></strong></a></span><p style="position:absolute; top:8px;"><img src="/{tpldir}images/informacao/line.png" width="263" height="38" /></p></li>
</ul>
</div>
<div class="info_fim"></div>
<br />
<div class="conf_top"></div>
<div class="info_meio">
<ul>
<li>
<p style=" padding-left:5px; position:absolute;"><img src="/{tpldir}images/informacao/ponto.png" width="16" height="16" /></p>
<span style="margin-left:25px;">Vers&atilde;o: <strong><?=$VERSAO;?></strong></span>
<p style="position:absolute; top:8px;"><img src="/{tpldir}images/informacao/line.png" width="263" height="38" /></p>
</li>

<li>
<p style=" padding-left:5px; position:absolute;"><img src="/{tpldir}images/informacao/ponto.png" width="16" height="16" /></p>
<span style="margin-left:25px;">Experi&ecirc;ncia: <strong><?=$EXP;?></strong></span>
<p style="position:absolute; top:8px;"><img src="/{tpldir}images/informacao/line.png" width="263" height="38" /></p>
</li>


<li>
<p style=" padding-left:5px; position:absolute;"><img src="/{tpldir}images/informacao/ponto.png" width="16" height="16" /></p><span style="margin-left:25px;">Drops: <strong><?=$DROP;?></strong></span>
<p style="position:absolute; top:8px;"><img src="/{tpldir}images/informacao/line.png" width="263" height="38" /></p></li>

<li>
<p style=" padding-left:5px; position:absolute;"><img src="/{tpldir}images/informacao/ponto.png" width="16" height="16" /></p><span style="margin-left:25px;">Bug Bless: <strong><?=$BUGBLESS;?></strong></span>
<p style="position:absolute; top:8px;"><img src="/{tpldir}images/informacao/line.png" width="263" height="38" /></p></li>
</ul>
</div>
<div class="info_fim"></div>
<br />
<div class="equipe_top"></div>
<div class="equipe_meio">
                      
      <?
                       $db->Query("select name,accountid from character where ctlcode>=8 order by name");
                       for($b=0;$b<$db->GetRow();$b++) {
                        $Gm = $db->GetRow();
                            $status = $db->GetRow();($db->Query("select connectstat from memb_stat where memb___id='".$Gm[1]."'"));
                         switch($status[0]) {
                            case 0: $statusfinal = "<div class=\"game\"><p>$Gm[0]</p><p style=\"margin-top:-21px; margin-left:190px;\"><img src=\"/{tpldir}images/equipe/off.png\" /></p></div>"; break;
                        case 1: $statusfinal = "<div class=\"game\"><p>$Gm[0]</p><p style=\"margin-top:-21px; margin-left:190px;\"><img src=\"/{tpldir}images/equipe/on.png\" /></p></div>"; break;

                        }
                       ?><?=$statusfinal?><? } ?>
          </div>
<div class="equipe_footer"></div>
</div>
            <!-- //Body Right -->
            </div>

        <!-- //Body -->
     <div id="subbottom"></div>
<center>
<div class="footer">
<span style="margin-top:31px; margin-left:-220px; font-size:12px; width:400px; position:absolute; color:#FFF;">{title}<br /> <p style="font-size:10px;  width:400px; margin-top:-1px; color:#fff;  font-family:gadugi-Bold;">Adaptado Por: <a href="http://fteamdevelopers.com" target="_blank">F-Team Developers</a></p>
</span>
</div>
</center>
</body>
</html>